with open('output.txt', 'w', encoding='utf-8') as f:
    print('这是写入文件的内容', file=f)
    print('这是第二行内容', file=f)


# 输出到标准错误
import sys
print('这是一个错误信息', file=sys.stderr)


with open('logger.txt', 'w', encoding='utf-8') as content:
    message = 'important_message'
    print(message)
    print(message, file=content)